home *** CD-ROM | disk | FTP | other *** search
- Path: kbad.eglin.af.mil!rpi!not-for-mail
- From: brandon@criterion.com (Brandon Wallace)
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: Help with IOStreams needed!
- Date: 17 Apr 1996 19:02:34 -0000
- Organization: Nicholas|Applegate Capital Management, San Diego, CA
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4l3f8a$9mu@netlab.cs.rpi.edu>
- References: <4kupd8$khj@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 17 Apr 1996 17:28:41 GMT
-
- In article <4kupd8$khj@netlab.cs.rpi.edu>,
- vm@panix.com (Victor Muslin) writes:
- -> I am new to IOStreams, so please pardon if this is a silly question...
- ->
- -> I open a file as an ofstream. When I write to it I would like to lock it to
- -> ensure that no other process can write until I am done. In C I could've used
- -> an flock() to which I would pass a file descriptor obtained from open(). How
- -> do I do I find the file descriptor associated with an ofstream (or ostream for
- -> that matter)? Or, is there a better way to lock an output stream in C++?
-
- On my flavor of C++ (solaris2.4/SparcCompiler 4.0), you can do:
-
- ofstream file ("filename");
- file.rdbuf()->fd()
-
- to get the file descriptor.
- --
- Brandon Wallace
- Nicholas | Applegate Capital Management
- mailto:bman@houston.nacm.com
- http://www.houston.nacm.com/home-pages/brandon
- "I live life face down in the fast lane."
-
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-